package com.hckj.jianzhijia.fragments;

import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.BaseAdapter;

import com.avos.avoscloud.AVObject;
import com.avos.avoscloud.AVQuery;
import com.hckj.jianzhijia.JianzhijiaApplacation;
import com.hckj.jianzhijia.JobDetailsActivity;
import com.hckj.jianzhijia.R;
import com.hckj.jianzhijia.adapters.JobListAdapter;
import com.hckj.jianzhijia.adapters.PushListAdapter;
import com.hckj.jianzhijia.popupwindows.PushLongClickPopWin;

import java.util.ArrayList;

/**
 * Created by 赵奇隆 on 2016-03-14.
 */
public class PushListFragment extends ListViewFragment implements PushLongClickPopWin.PopWinInterface {


    AVQuery<AVObject> query = null;
    private int[] colorResource = {R.color.color_primary};
    private PushListAdapter pushListAdapter;
    private ArrayList<AVObject> avObjectArrayList;
    private View parentView;


    public static PushListFragment newInstance(View parentView) {
        PushListFragment fragment = new PushListFragment();
        Bundle args = new Bundle();
        fragment.setParentView(parentView);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        query = new AVQuery<AVObject>("PushInfo");
        avObjectArrayList = new ArrayList<AVObject>();
        pushListAdapter = new PushListAdapter(getActivity(), avObjectArrayList);
    }

    @Override
    public void cancelPushApplication(int position) {

    }

    @Override
    public void afterUpdateListFresh() {

    }

    @Override
    public BaseAdapter getListAdapter() {
        return pushListAdapter;
    }

    @Override
    public boolean useCustomContentView() {
        return false;
    }

    @Override
    public int getCustomContentView() {
        return 0;
    }

    @Override
    public boolean pullToRefreshEnabled() {
        return true;
    }

    @Override
    public int[] getPullToRefreshColorResources() {
        return colorResource;
    }

    @Override
    public void onRefresh() {

    }

    @Override
    public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {

    }

    @Override
    public boolean onItemLongClick(AdapterView<?> adapterView, View view, int position, long l) {
        PushLongClickPopWin pushLongClickPopWin = new PushLongClickPopWin(getActivity(), this, parentView,position);
        pushLongClickPopWin.showAtLocation(parentView, Gravity.CENTER, 0, 0);
        return true;
    }

    public void setParentView(View parentView) {
        this.parentView = parentView;
    }

}
